package com.byit.async;

import com.byit.domain.AppApplictionMenu;
import com.byit.solr.ISolrService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

/**
 * 异步同步solr application_menu
 *
 * @author tjm
 * @date 2019/1/15.
 */
@Component
@Slf4j
public class AppMenuSolrAsync {

    @Autowired
    private ISolrService<AppApplictionMenu> solrService;
    /**
     * 添加和更新同步solr
     */
    @Async
    public void save(AppApplictionMenu menu){
        try {
            solrService.addOrUpdate(menu);
        }catch (Exception e){
            log.error(e.getMessage());
        }
    }

    /**
     * 删除同步solr
     */
    @Async
    public void del(String ids){
        try {
            solrService.delete(ids);
        }catch (Exception e){
            log.error(e.getMessage());
        }
    }
}
